home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / man / catn / exec.n < prev    next >
Text File  |  1994-09-20  |  10KB  |  265 lines

  1.  
  2.  
  3.  
  4. exec(n)               Tcl Built-In Commands                   7.0
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NAME
  11.      exec - Invoke subprocess(es)
  12.  
  13. SYNOPSIS
  14.      exec ?_s_w_i_t_c_h_e_s? _a_r_g ?_a_r_g ...?
  15. _________________________________________________________________
  16.  
  17.  
  18. DESCRIPTION
  19.      This command treats its arguments as  the  specification  of
  20.      one or more subprocesses to execute.  The arguments take the
  21.      form of a standard shell pipeline where each _a_r_g becomes one
  22.      word  of a command, and each distinct command becomes a sub-
  23.      process.
  24.  
  25.      If the initial arguments to exec start with - then they  are  |
  26.      treated  as  command-line  switches  and are not part of the  |
  27.      pipeline  specification.    The   following   switches   are  |
  28.      currently supported:                                          |
  29.  
  30.      -keepnew-  |
  31.                   line                                                       ||
  32.                   Retains a trailing newline  in  the  pipeline's  |
  33.                   output.   Normally  a  trailing newline will be  |
  34.                   deleted.                                         |
  35.  
  36.      --                                                                 ||
  37.                   Marks  the  end of switches.  The argument fol-  |
  38.                   lowing this one will be treated  as  the  first  |
  39.                   _a_r_g even if it starts with a -.
  40.  
  41.      If an _a_r_g (or pair of _a_r_g's) has one of the forms  described
  42.      below  then  it is used by exec to control the flow of input
  43.      and output among the subprocess(es).   Such  arguments  will
  44.      not  be  passed to the subprocess(es).  In forms such as ``<  |
  45.      _f_i_l_e_N_a_m_e'' _f_i_l_e_N_a_m_e may either be  in  a  separate  argument  |
  46.      from ``<'' or in the same argument with no intervening space  |
  47.      (i.e. ``<_f_i_l_e_N_a_m_e'').
  48.  
  49.      |              Separates distinct commands in the  pipeline.
  50.                     The  standard output of the preceding command
  51.                     will be piped into the standard input of  the
  52.                     next command.
  53.  
  54.      |&             Separates distinct commands in the  pipeline.
  55.                     Both  standard  output  and standard error of
  56.                     the preceding command will be piped into  the
  57.                     standard  input  of  the  next command.  This
  58.                     form of redirection overrides forms  such  as
  59.                     2> and >&.
  60.  
  61.  
  62.  
  63. Tcl                                                             1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. exec(n)               Tcl Built-In Commands                   7.0
  71.  
  72.  
  73.  
  74.      < _f_i_l_e_N_a_m_e     The file named by _f_i_l_e_N_a_m_e is opened and used
  75.                     as  the  standard input for the first command
  76.                     in the pipeline.
  77.  
  78.      <@ _f_i_l_e_I_d      _F_i_l_e_I_d must be the  identifier  for  an  open  |
  79.                     file,  such as the return value from a previ-  |
  80.                     ous call to open.  It is used as the standard  |
  81.                     input  for the first command in the pipeline.  |
  82.                     _F_i_l_e_I_d must have been opened for reading.
  83.  
  84.      << _v_a_l_u_e       _V_a_l_u_e is passed to the first command  as  its
  85.                     standard input.
  86.  
  87.      > _f_i_l_e_N_a_m_e     Standard output  from  the  last  command  is
  88.                     redirected   to   the  file  named  _f_i_l_e_N_a_m_e,
  89.                     overwriting its previous contents.
  90.  
  91.      2> _f_i_l_e_N_a_m_e    Standard error from all commands in the pipe-  |
  92.                     line   is   redirected   to  the  file  named  |
  93.                     _f_i_l_e_N_a_m_e, overwriting its previous contents.   |
  94.  
  95.      >& _f_i_l_e_N_a_m_e                                                        ||
  96.                     Both  standard  output  from the last command  |
  97.                     and standard  error  from  all  commands  are  |
  98.                     redirected   to   the  file  named  _f_i_l_e_N_a_m_e,  |
  99.                     overwriting its previous contents.
  100.  
  101.      >> _f_i_l_e_N_a_m_e    Standard output  from  the  last  command  is
  102.                     redirected   to   the  file  named  _f_i_l_e_N_a_m_e,
  103.                     appending to it rather than overwriting it.
  104.  
  105.      2>> _f_i_l_e_N_a_m_e   Standard error from all commands in the pipe-  |
  106.                     line   is   redirected   to  the  file  named  |
  107.                     _f_i_l_e_N_a_m_e,  appending  to   it   rather   than  |
  108.                     overwriting it.                                |
  109.  
  110.      >>& _f_i_l_e_N_a_m_e                                                       ||
  111.                     Both  standard  output  from the last command  |
  112.                     and standard  error  from  all  commands  are  |
  113.                     redirected   to   the  file  named  _f_i_l_e_N_a_m_e,  |
  114.                     appending to it rather than overwriting it.    |
  115.  
  116.      >@ _f_i_l_e_I_d                                                          ||
  117.                     _F_i_l_e_I_d  must  be  the  identifier for an open  |
  118.                     file, such as the return value from a  previ-  |
  119.                     ous  call  to open.  Standard output from the  |
  120.                     last command is redirected to _f_i_l_e_I_d's  file,  |
  121.                     which must have been opened for writing.       |
  122.  
  123.      2>@ _f_i_l_e_I_d                                                         ||
  124.                     _F_i_l_e_I_d  must  be  the  identifier for an open  |
  125.                     file,  such  as  the  return  value  from   a  |
  126.  
  127.  
  128.  
  129. Tcl                                                             2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. exec(n)               Tcl Built-In Commands                   7.0
  137.  
  138.  
  139.  
  140.                     previous  call  to open.  Standard error from  |
  141.                     all commands in the pipeline is redirected to  |
  142.                     _f_i_l_e_I_d's  file.   The  file  must  have  been  |
  143.                     opened for writing.                            |
  144.  
  145.      >&@ _f_i_l_e_I_d                                                         ||
  146.                     _F_i_l_e_I_d  must  be  the  identifier for an open  |
  147.                     file, such as the return value from a  previ-  |
  148.                     ous  call to open.  Both standard output from  |
  149.                     the last command and standard error from  all  |
  150.                     commands  are  redirected  to  _f_i_l_e_I_d's file.  |
  151.                     The file must have been opened for writing.
  152.  
  153.      If standard output has not been  redirected  then  the  exec
  154.      command returns the standard output from the last command in
  155.      the pipeline.  If any of the commands in the  pipeline  exit
  156.      abnormally or are killed or suspended, then exec will return
  157.      an error and the error message will include  the  pipeline's
  158.      output  followed  by  error messages describing the abnormal
  159.      terminations; the errorCode variable will contain additional
  160.      information about the last abnormal termination encountered.
  161.      If any of the commands writes to its standard error file and
  162.      that  standard error isn't redirected, then exec will return
  163.      an error;  the error message  will  include  the  pipeline's
  164.      standard  output, followed by messages about abnormal termi-
  165.      nations (if any), followed by the standard error output.
  166.  
  167.      If the last character of the result or error  message  is  a
  168.      newline  then  that  character  is normally deleted from the
  169.      result or error message.  This is consistent with other  Tcl
  170.      return values, which don't normally end with newlines.  How-  |
  171.      ever, if -keepnewline is specified then the trailing newline  |
  172.      is retained.
  173.  
  174.      If standard input isn't redirected with ``<'' or  ``<<''  or
  175.      ``<@''  then the standard input for the first command in the
  176.      pipeline is taken from the  application's  current  standard
  177.      input.
  178.  
  179.      If the last _a_r_g is ``&'' then the pipeline will be  executed
  180.      in  background.  In this case the exec command will return a  |
  181.      list whose elements are the process identifiers for  all  of  |
  182.      the  subprocesses in the pipeline.  The standard output from
  183.      the  last  command  in  the  pipeline   will   go   to   the
  184.      application's  standard output if it hasn't been redirected,
  185.      and error output from all of the commands  in  the  pipeline
  186.      will  go  to  the  application's  standard error file unless
  187.      redirected.
  188.  
  189.      The first word in each command is taken as the command name;
  190.      tilde-substitution  is  performed  on  it, and if the result
  191.      contains  no  slashes  then  the  directories  in  the  PATH
  192.  
  193.  
  194.  
  195. Tcl                                                             3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. exec(n)               Tcl Built-In Commands                   7.0
  203.  
  204.  
  205.  
  206.      environment  variable  are searched for an executable by the
  207.      given name.  If the name contains a slash then it must refer
  208.      to  an  executable reachable from the current directory.  No
  209.      ``glob'' expansion or  other  shell-like  substitutions  are
  210.      performed on the arguments to commands.
  211.  
  212.  
  213. KEYWORDS
  214.      execute, pipeline, redirection, subprocess
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. Tcl                                                             4
  262.  
  263.  
  264.  
  265.